﻿using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;

namespace 使用杨中科的读取数据库配置
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ConfigurationBuilder builder = new ConfigurationBuilder();
            builder.AddDbConfiguration(()=>new SqlConnection("Server=.;database=classT;uid=sa;pwd=sa;Encrypt=True;TrustServerCertificate=True;"),reloadOnChange:true,reloadInterval:TimeSpan.FromSeconds(2));
            IConfigurationRoot configuration = builder.Build();
            Teacher t = configuration.Get<Teacher>();
            Console.WriteLine(t);
            Console.ReadLine();
        }
    }
}
